
package com.primeton.eos.oss.model.service;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.eos.system.utility.PageResultList;

import com.eos.data.datacontext.DataContextManager;
import com.eos.data.datacontext.IMUODataContext;

import com.primeton.eos.oss.model.dao.CrecSysOrganizationDao;
import com.primeton.eos.oss.model.newdataset.CrecSysOrganization;

@Service
public class CrecSysOrganizationService {

    @Autowired
    private CrecSysOrganizationDao crecSysOrganizationDao;


    public PageResultList<CrecSysOrganization> queryCrecSysOrganizationsWithPage(String code,  int pageSize, int pageIndex) {
        //TODO 记录日志
        return crecSysOrganizationDao.queryCrecSysOrganizationsWithPage(code,  pageSize, pageIndex);
    }

    public CrecSysOrganization getCrecSysOrganizationById(String id) {
        //TODO 记录日志
        return crecSysOrganizationDao.getEntity(CrecSysOrganization.QNAME, id);
    }

    @Transactional
    public void createCrecSysOrganization(CrecSysOrganization crecSysOrganization) {
        //TODO 记录日志
    	String userName = "";
		IMUODataContext muo = DataContextManager.current().getMUODataContext();
		if (muo != null) {
			userName = muo.getUserObject().getUserName();
		}
        crecSysOrganization.set("createUser", userName);
        crecSysOrganization.set("createTime", new Date());
        crecSysOrganization.set("updateUser", userName);
        crecSysOrganization.set("updateTime", new Date());

        crecSysOrganizationDao.getPrimaryKey(crecSysOrganization);
        crecSysOrganizationDao.insertEntity(crecSysOrganization);
    }
    
    @Transactional
    public void modifyCrecSysOrganization(CrecSysOrganization crecSysOrganization) {
        //TODO 记录日志
     	String userName = "";
		IMUODataContext muo = DataContextManager.current().getMUODataContext();
		if (muo != null) {
			userName = muo.getUserObject().getUserName();
		}
        crecSysOrganization.set("updateUser", userName);
        crecSysOrganization.set("updateTime", new Date());
 
        crecSysOrganizationDao.updateEntity(crecSysOrganization);
    }
    
     @Transactional
    public void removeCrecSysOrganization(CrecSysOrganization[] crecSysOrganization) {
        //TODO 记录日志
        crecSysOrganizationDao.deleteEntity(crecSysOrganization);
    }

}





